home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4358 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. Path: nntp-xfer-2.csn.net!yuma!steffend
  2. From: steffend@lamar.colostate.edu (Dave Steffen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie question on syntax of pointer to const
  5. Date: 29 Jan 1996 22:43:49 GMT
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Message-ID: <4ejij5$3630@yuma.ACNS.ColoState.EDU>
  8. References: <4ej9eg$lq6@agate.berkeley.edu>
  9. NNTP-Posting-Host: glitch.physics.colostate.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. David C. Parsons (parsons@vouvray.CS.Berkeley.EDU) wrote:
  13. > In a declaration of a const reference or const pointer type, does it matter
  14. > in what the order the keyword const and the underlying type appear?  That
  15. > is, are
  16.  
  17. > (1)    const double *pc;    and
  18. > (2)    double const *pc;
  19.  
  20. > both acceptable syntax for type "pointer to constant double"?  (My book only
  21. > describes (1), but my compiler accepts either.)
  22.  
  23.     I'm not sure what 2) should mean, which is probably your
  24. problem. The three possibilities I'm aware of are
  25.  
  26.     const double*       pc;    // pointer to constant double
  27.           double* const pc; // const pointer to double
  28.     const double* const pc; // const pointer to const double
  29.  
  30. when you write "double const *", AFAIK that doesn't fit in with the syntax
  31. of the language. I _think_ that your compiler is (wrongly) accepting
  32. 2) as meaning one of the above; but which one is anybody's guess.
  33.  
  34.     However, I'm not sure this is your problem (although it _is_
  35. important to get right ;-)
  36.  
  37. > The reason I ask is because I'm getting the following error from the linker:
  38.  
  39. > /bin/ld: Unsatisfied symbols:
  40. >    operator<<(ostream &, Matrix<double> const &)(code)
  41. >    Matrix<double>::Matrix(Matrix<double> const &)(code)
  42.  
  43. > even though I have definitions like these:
  44.  
  45. >     template <class Type>
  46. >     ostream& operator <<( ostream& os, const Matrix<Type>& m )
  47. >     {    ...    }
  48.  
  49. >     template <class Type>
  50. >     Matrix<Type>::Matrix( const Matrix<Type> &m )
  51. >     {    ...    }
  52.  
  53. > Are the function prototypes in the error message different from these in
  54. > some way I'm overlooking?
  55.  
  56.     These look fine at first glance, the problem is probably a
  57. template issue with your compiler. Most compilers are still iffy
  58. regarding template issues; GNU G++ 2.7.0 essentially requires the
  59. _definitions_ of your templates in the _header_ files. My older
  60. version of Borland (3.1 I think) requires the same thing.
  61.  
  62.     So check the docs on your compiler carefully and make sure
  63. it's finding the template definitions where it wants them to be.
  64.  
  65.                                  /\
  66.                                  \/
  67.  
  68. Dave Steffen                      No, his mind is not for rent
  69. Dept. of Physics                  To any God or Government
  70. Colorado State University         Always hopeful, yet discontent
  71. steffend@lamar.colostate edu      He knows changes aren't permanent-
  72.                       But change is...
  73. "Speak softly...                    
  74. ... and carry a black belt!"              -Neal Peart / RUSH
  75. -----------------------------------------------------------------------
  76.  
  77.  
  78.  
  79.